{{!
  Copyright (c) HashiCorp, Inc.
  SPDX-License-Identifier: BUSL-1.1
}}

<div class="box is-shadowless">
  <PageHeader as |p|>
    <p.top>
      <Hds::Breadcrumb>
        <Hds::Breadcrumb::Item
          @text={{if this.model.backend this.model.backend "Secrets"}}
          @route={{if this.model.backend "vault.cluster.secrets.backend.list-root" "vault.cluster.secrets"}}
        />
      </Hds::Breadcrumb>
    </p.top>
    <p.levelLeft>
      <h1 class="title is-3 has-text-grey" data-test-backend-error-title>
        {{#if (eq this.model.httpStatus 404)}}
          404 Not Found
        {{else if (eq this.model.httpStatus 403)}}
          Not Authorized
        {{else}}
          Error
        {{/if}}
      </h1>
    </p.levelLeft>
  </PageHeader>
  <div class="box is-sideless has-background-white-bis has-text-grey has-text-centered">
    {{#if (eq this.model.httpStatus 404)}}
      <p data-test-secret-not-found>
        Unable to find secret at
        <code>{{concat this.model.backend "/" this.model.secret}}</code>. Try going back to the
        <LinkTo @route={{if this.model.backend "vault.cluster.secrets.backend.list-root" "vault.cluster.secrets"}}>
          root
        </LinkTo>
        and navigating from there.
      </p>
    {{else if (eq this.model.httpStatus 403)}}
      {{#if (eq this.model.policyPath "sys/capabilities-self")}}
        <p>
          Your auth token does not have access to
          <code>{{this.model.policyPath}}</code>. Vault Enterprise uses this endpoint to determine what actions are allowed
          in the interface.
        </p>
        <p>
          Make sure the policy for the path
          <code>{{this.model.policyPath}}</code>
          includes
          <code>capabilities = ['update']</code>.
        </p>
      {{else}}
        <p>
          You don't have access to
          <code>
            {{if this.model.secret (concat this.model.backend "/" this.model.secret) (concat this.model.backend "/")}}
          </code>. If you think you've reached this page in error, please contact your administrator.
        </p>
        <p>
          {{#if this.model.secret}}
            <LinkTo @route="vault.cluster.secrets.backend.list-root">Navigate back to the root</LinkTo>.
          {{else}}
            <LinkTo @route="vault.cluster">Go back home</LinkTo>.
          {{/if}}
        </p>
      {{/if}}
    {{else}}
      {{#if this.model.message}}
        <p>{{this.model.message}}</p>
      {{/if}}
      {{#each this.model.errors as |error|}}
        <p class="message">
          {{error}}
        </p>
      {{/each}}
    {{/if}}
  </div>
</div>